#pragma once

#include <GL/glew.h>
#include "../vectormath.h"
#include "../ShaderManager.h"
#include <vector>

namespace Tmpl {

struct Vertex
{
	Vec3f pos;
	Vec3f normal;
	Vec2f uv;
};

typedef std::vector<Vertex> VertexArray;
typedef std::vector<GLuint> IndicesArray;

class Model
{
public:
	Model(ShaderProgram* shader);
	virtual ~Model();

	virtual void Render(const Matrix4x4f& projection, const Matrix4x4f* modelView, int count);

	virtual int GetTriangleCount(){return (mIndicesCount > 0) ? mIndicesCount / 3 : mVertexCount / 3 ;}

	void BuildModel(const VertexArray& vertices, const IndicesArray& indices);
protected:
	virtual void BindSettings(){}
	virtual void UnbindSettings(){}

	ShaderProgram* mShader;
	GLuint mRenderMode;
	GLuint mVBO;
	GLuint mVBOIndices;
	GLuint mVAB;
	GLuint mIndicesCount;
	GLuint mVertexCount;
	GLuint mBufferObjectId;
};

}; // namespace Tmpl